package com.gxa.saas.admin.controller;


import com.gxa.saas.admin.service.AdminService;
import com.gxa.saas.core.entity.Admin;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import com.gxa.saas.core.common.JsonResult;
import com.gxa.saas.core.entity.Admin;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.velocity.runtime.directive.MacroParseException;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Api(tags = "总后台登录模块")
@Controller
public class LoginController {

    @Autowired
    AdminService adminService;

    @ApiOperation(value = "登录接口")
    @GetMapping("/admin/Login")
    @ResponseBody
    public Map adminLogin(Admin admin){
        Map map = new HashMap();
        Integer login = adminService.login(admin.getAName(), admin.getAPwd());
        if (login == null){
         map.put("code",401);
         map.put("msg","账号和密码错误");
         return map;
        }else{
            map.put("msg","登录成功");
            map.put("code",200);
            map.put("data", UUID.randomUUID());
        }
        System.out.println("aName:--->"+ admin.getAName());
        System.out.println("aPwd:--->"+admin.getAPwd());

        return map;

    }
}
